# Pull base image
#FROM jrottenberg/ffmpeg:4.0-ubuntu
FROM ubuntu:20.04
USER root
MAINTAINER Gonsin

ENV TZ=Asia/Shanghai
ENV LANG C.UTF-8

RUN mv /etc/apt/sources.list /etc/apt/sources.list.bk
COPY sources.list /etc/apt/sources.list

RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt install -y tzdata

RUN apt-get install -y vim
RUN apt-get install -y zip
RUN apt-get install -y wget
RUN apt-get install -y git
RUN apt-get install -y python3
RUN apt-get install -y python2
RUN apt-get install -y ffmpeg

RUN wget http://update.gonsincloud.com/jenkins/openjdk-11.0.2_linux-x64_bin.tar.gz \
    && tar zxvf openjdk-11.0.2_linux-x64_bin.tar.gz -C /usr/local/
ENV JAVA_HOME /usr/local/jdk-11.0.2
ENV JRE_HOME $JAVA_HOME/jre
ENV CLASSPATH $JAVA_HOME/lib:$JRE_HOME/lib
ENV PATH $PATH:$JAVA_HOME/bin
RUN java -version
RUN javac -version

# 安装node
RUN wget -nc http://update.gonsincloud.com/jenkins/node-v14.20.1-linux-x64.tar.xz \
    && tar xvJf node-v14.20.1-linux-x64.tar.xz -C /usr/local/
ENV NPM_HOME /usr/local/node-v14.20.1-linux-x64
ENV PATH $PATH:$NPM_HOME/bin
RUN npm -version \
    && npm config set registry https://registry.npmmirror.com \
    && npm install -g npm@9.6.3 --unsafe-perm
#    && npm install -g mirror-config-china --registry=https://registry.npmmirror.com

# 安装gradle
#RUN wget -nc http://update.gonsincloud.com/jenkins/gradle-7.6.1-all.zip \
#    && mv gradle-7.6.1-all.zip /usr/local/ \
#    && unzip -d /usr/local/ /usr/local/gradle-7.6.1-all.zip \
#    && chmod +x /usr/local/gradle-7.6.1/bin/gradle \
#    && chmod 777 /usr/local/gradle-7.6.1/bin
#ENV GRADLE_HOME /usr/local/gradle-7.6.1
#ENV PATH $PATH:$GRADLE_HOME/bin
#ENV CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL file:///usr/local/gradle-7.6.1-all.zip
#COPY init.gradle /usr/local/gradle-7.6.1/init.d/init.gradle
#RUN gradle -version

# 安装安卓SDK
#RUN wget -nc http://update.gonsincloud.com/jenkins/commandlinetools-linux-8512546_latest.zip \
#    && mkdir /usr/local/android \
#    && mv commandlinetools-linux-8512546_latest.zip /usr/local/android/ \
#    && unzip -d /usr/local/android/sdk/ /usr/local/android/commandlinetools-linux-8512546_latest.zip \
#    && mkdir /usr/local/android/sdk/cmdline-tools/latest \
#    && mv /usr/local/android/sdk/cmdline-tools/bin  /usr/local/android/sdk/cmdline-tools/latest/bin \
#    && mv /usr/local/android/sdk/cmdline-tools/lib  /usr/local/android/sdk/cmdline-tools/latest/lib \
#    && mv /usr/local/android/sdk/cmdline-tools/NOTICE.txt  /usr/local/android/sdk/cmdline-tools/latest/NOTICE.txt \
#    && mv /usr/local/android/sdk/cmdline-tools/source.properties  /usr/local/android/sdk/cmdline-tools/latest/source.properties

#ENV ANDROID_HOME /usr/local/android/sdk/
#ENV ANDROID_SDK_ROOT /usr/local/android/sdk/
#ENV PATH $PATH:$ANDROID_HOME/cmdline-tools/latest/bin
#RUN sdkmanager --list \
#    && yes | sdkmanager --install "platform-tools" \
#    && yes | sdkmanager --install "build-tools;30.0.3" \
#    && yes | sdkmanager --install "build-tools;33.0.2" \
#    && yes | sdkmanager --install "emulator" \
#    && yes | sdkmanager --install "tools" \
##    && yes | sdkmanager --install "platforms;android-28" \
#    && yes | sdkmanager --install "platforms;android-30" \
#    && yes | sdkmanager --install "platforms;android-31" \
#    && yes | sdkmanager --install "platforms;android-32" \
#    && yes | sdkmanager --install "platforms;android-33" \
##    && yes | sdkmanager --install "patcher;v4" \
#    && yes | sdkmanager --licenses
#
#RUN npm install -g cordova@12.0.0 \
#    && npm update cordova -g \
#    && mkdir /opt/cordova_project

## 安装aapt
RUN wget http://update.gonsincloud.com/v/apktool
RUN wget http://update.gonsincloud.com/v/apktool_2.3.3.jar
RUN wget http://update.gonsincloud.com/v/aapt
RUN mkdir /usr/local/apktool
RUN mv apktool_2.3.3.jar apktool.jar
RUN mv apktool apktool.jar aapt /usr/local/apktool
RUN chmod 777 /usr/local/apktool/apktool /usr/local/apktool/apktool.jar /usr/local/apktool/aapt
RUN apt-get update
RUN apt-get install -y libc6-i386 lib32stdc++6 lib32gcc1 lib32z1
ENV AAPT_HOME /usr/local/apktool
ENV PATH $PATH:$AAPT_HOME



